package com.fandy.struts.SqlStatement;

public class Staff {
 
	public   String  getAll()
	{
		return   "select ID from Staff";
	}
	
	public   String getStaffInfoByID(int ID)
	{
		return  "select * from Staff where " +com.fandy.struts.Meta.Staff.getStaffid()+"="+ID;
	}
	
	public   String getStaffInfoByName(String userName)
	{
		userName = userName.replace('\'', '_');
		userName = userName.replace('=', '_');
		return  "select * from Staff where " +com.fandy.struts.Meta.Staff.getName()+"='"+userName+"'";
	}
	
	
	public   String  existStaff4Login(com.fandy.struts.Model.Staff s)
	{
		return  "select count(*) from Staff where " +com.fandy.struts.Meta.Staff.getName()+"='"
		+s.getName()+"' "
		+"and PassWord = '" 
		+ s.getPassword() 
		+ "'";
	}
	
	
	public   String  existStaff(String s)
	{
		return  "select count(*) from Staff where "+ com.fandy.struts.Meta.Staff.getName() + "= '"
		+s + "' "				 
		;
	}
	
	
	public String Add(com.fandy.struts.Model.Staff s)
	{
		
		return "insert into Staff values ("
		+ "'" + s.getAddress()+"',"		 
		+ "'" + s.getAuthority()+"',"
		+ "'"  + s.getContact() + "',"
		+ "'"  + s.getDepartmentid()+ "',"
		+ "'"  + s.getName()+ "',"
		+ "'"  + s.getPassword()+ "',"
		+ "'"  + s.getSalary() + "'"
		 		
		+")"
		;
		
	}
	
	
	public String UpdateByID(int id,com.fandy.struts.Model.Staff s)
	{
		
		return "update Staff set "+com.fandy.struts.Meta.Staff.getAddress()
		+"='" + s.getAddress()+"',"		 
		+com.fandy.struts.Meta.Staff.getAuthority()+"='" +s.getAuthority()+"',"
		+com.fandy.struts.Meta.Staff.getContact()+ "='"  + s.getContact() + "',"
		+com.fandy.struts.Meta.Staff.getDepartmentid()+ "='"  + s.getDepartmentid() + "',"
		+com.fandy.struts.Meta.Staff.getName() + "='"  + s.getName() + "',"
		+com.fandy.struts.Meta.Staff.getPassword() + "='"  + s.getPassword() + "',"
		+com.fandy.struts.Meta.Staff.getSalary() + "='"  + s.getSalary()+ "'"		
		+"where "+com.fandy.struts.Meta.Staff.getStaffid()+"="+id;
		
	}
	
	public String DeleteByID(int id)
	{
		
		return "delete from staff where " + com.fandy.struts.Meta.Staff.getStaffid() +"="+id;
		
	}
	
	
	
}

